<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<title>报警记录</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand" />  
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" type="text/css" href="layui/css/layui.css" media="all">
	<link rel="stylesheet" type="text/css" href="css/index.css"/>
</head>

<body>
<section class="layui-larry-box">
	<div class="larry-personal">
		<div class="layui-tab">
			<blockquote class="layui-elem-quote mylog-info-tit" style="background: #fff;">
				<ul class="handle-box" id="conditions">
					<li class="handle-item">
					</li>
				</ul>
				<div class="layui-tab-item layui-field-box layui-show">
					<table class="table-box table-sort" id="message" lay-even="" lay-skin="nob"></table>
				</div>
			</blockquote>
		</div>
	</div>
</section>
<script type="text/javascript" src="layui/layui.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<!-- tab table-->
<script type="text/javascript" src="js/vue/vue.js"></script>
<script src="//cdn.bootcss.com/jquery/3.2.0/jquery.js"></script>
<script src="//cdn.bootcss.com/vue-resource/1.2.1/vue-resource.js"></script>
<script src="//cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
<script src="http://cdn.datatables.net/plug-ins/28e7751dbec/integration/bootstrap/3/dataTables.bootstrap.js"></script>
<script type="text/javascript">

	layui.use('laydate', function() {
		var laydate = layui.laydate;
		var $ = layui.jquery;

	});

	var vue = new Vue({
		el: '#conditions',
		data: {
			deviceName: "",
			myTable:null,
			
		},
		mounted: function () {
			this.message_init();
		},
		methods: {
			message_init:function () {
				var start =  replaceTime(startTimes / 1000);
				if(endTimes == 'read=0'){
					var timestamp = (new Date()).valueOf();
					var end = replaceTime(timestamp / 1000);
				}else{
					var end =  replaceTime(endTimes / 1000);
				}
				
				var myTable = $('#message').DataTable({
					//开启服务器模式
					"processing": false, //DataTables载入数据时，是否显示‘进度’提示  
				      "stateSave": true, //是否打开客户端状态记录功能,此功能在ajax刷新纪录的时候不会将个性化设定回复为初始化状态  
				      "scrollCollapse": true, //是否开启DataTables的高度自适应，当数据条数不够分页数据条数的时候，插件高度是否随数据条数而改变  
				      "paginationType": "full_numbers", //详细分页组，可以支持直接跳转到某页  
				      "language": lang, //提示信息
				      "autoWidth": false, //自适应宽度，
				      "lengthMenu": [20, 30, 50],
				      "stripeClasses": ["odd", "even"], //为奇偶行加上样式，兼容不支持CSS伪类的场合
				      "searching": false, //是否允许Datatables开启本地搜索
				      "paging": true, //是否开启本地分页
				      "lengthChange": true, //是否允许产品改变表格每页显示的记录数
				      "info": false, //控制是否显示表格左下角的信息
					//跟数组下标一样，第一列从0开始，这里表格初始化时，第四列默认降序
					"ordering": false,
					"deferRender": true, //延迟渲染
					"ajax": {
						url : url + '/ic-iot/device/'+deviceId+'/alarm/records/history',//users
						type : 'get',
						data:{
							"pageSize":20,
							"currentPage":1,
							"startTime":start,
							"endTime": end,
						},
						dataType : 'json',
						beforeSend: function(request) {
							request.setRequestHeader("accessToken", accessToken);
						},
						success: function(data) {
							if(data['code'] == 1){
								if(data.result.data.length != 0)
									$('#message').dataTable().fnAddData(data.result.data);
								else
									$('#message').dataTable().fnClearTable();
							}else{
								ifajax(data);
							}
						}
					}, //数据的路径 "http://192.168.5.133:8081/ic-iot/admin/'+adminId+'/devices" /"json/device.json"
					select: { //单击tr选中当前行
						style: 'multi'
					},
					"columns": [{
						"data": function(obj) {
                            if(obj.tem || obj.hum){
                                var tem = !obj.tem ? '- -' : obj.tem + '℃';
                                var hum = !obj.hum ? '- -' : obj.hum + '%';
                                return  tem +' '+ hum;
                            }else{
                                var temCh1 = (obj.temCh1 == '' || obj.temCh1 == null) ? '- -' : obj.temCh1 + '℃';
                                var humCh1 = (obj.humCh1 == '' || obj.humCh1 == null) ? '- -' : obj.humCh1 + '%';
                                return  temCh1 +' '+ humCh1;
                            }
						},
						"sTitle": "通道一温湿度", //标题
						"sDefaultContent": "" //此列默认值为""，以防数据中没有此值，DataTables加载数据的时候报错
					},{
						"data": function(obj) {
							var humCh2 = (obj.humCh2 == '' || obj.humCh2 == undefined || obj.humCh2 == null) ? '- -' : obj.humCh2 + '%';
							var temCh2 = (obj.temCh2 == '' || obj.temCh2 == undefined || obj.temCh2 == null) ? '- -' : obj.temCh2 + '℃';
							return  temCh2 +' '+ humCh2;
						},
						"sTitle": "通道二温湿度", //标题
						"sDefaultContent": "", //此列默认值为""，以防数据中没有此值，DataTables加载数据的时候报错
					},{
						"data":  function(obj) {
						 	return obj.exDetail
						},
						"sTitle": "报警原因", //标题
						"sType": 'chinese',
						"sDefaultContent": "", //此列默认值为""，以防数据中没有此值，DataTables加载数据的时候报错
					},{
						"data": function(obj) {
							return obj.stateInfo
						},
						"sTitle": "异常类型", //标题
						"sDefaultContent": "", //此列默认值为""，以防数据中没有此值，DataTables加载数据的时候报错
					},{
						"data": function(obj) {
							return obj.recordTimeInfo;
						},
						"sTitle": "开始时间", //标题
						"sDefaultContent": "", //此列默认值为""，以防数据中没有此值，DataTables加载数据的时候报错
					}]
				});
			},
			message_cx: function () {
				
				this.message_init();
			}
		}
	}
	);
</script>
</body>
</html>


